const { segment } = require("oicq")
const { bot } = require("../index")
const { noPunch } = require('./plugin-picPunch')
const { info } = require('./myconfig')
//node在使用时必须每次引入axios
const axios = require('axios')
// 回复图片
bot.on("message.private", function (msg) {
  if (msg.raw_message === "支付宝红包") {
    msg.reply(segment.image("https://hanruofei-gogogo.oss-cn-chengdu.aliyuncs.com/images/202209301105820.jpg"))
  }
  if (msg.raw_message === '今日核酸截图') {
    noPunch(msg)
    return
  }
  // 检测是否骂人
  const maren = info.abuse.say
  const replymaren = info.abuse.answer

  if (info.abuse.say.includes(msg.raw_message)) {
    msg.reply(info.abuse.answer[Math.floor(Math.random() * info.abuse.answer.length)])
  }
  if (maren.includes(msg.raw_message)) {
    msg.reply(replymaren[Math.floor(Math.random() * replymaren.length)])
    // msg.reply('日你妈的批！', true)
  }
  else {
    let text = msg.raw_message.trim()
    axios.get(`https://api.ownthink.com/bot?spoken=${encodeURI(text)}`)
      .then((res) => {
        if (res.data.message === 'success') {
          let replyInfo = res.data.data.info.text
          console.log(replyInfo)
          msg.reply(replyInfo, false)
        }
        else {
          console.log('失败了！')
          msg.reply('不理笨蛋~哼哼哼', false)
        }
      })
      .catch((e) => {
        console.log(`不能说话，因为${e}`)
        msg.reply(`不能说话，因为${e}`, false)
      })
  }
  //情话语录 api:https://api.uomg.com/api/rand.qinghua?format=json
})

